#!/bin/sh

PROG=${TEST_BINARY_DIR}/test_basic

for _tin in ${TEST_DIR}/basic/*.in ; do
	_t=`echo $_tin | sed -e 's/.in$//'`
	_out=${TEST_OUT_DIR}/basic.out
	$PROG $_t.in $_out
	if [ $? -ne 0 ] ; then
		echo "Test: $_t failed, output:"
		cat $_out
		rm $_out
		exit 1
	fi
	if [ -f $_t.res ] ; then
	diff -s $_out $_t.res -u 2>/dev/null
		if [ $? -ne 0 ] ; then
			rm $_out
			echo "Test: $_t output mismatch"
			exit 1
		fi
	fi
	rm $_out
	# Use FD interface
	$PROG -f $_t.in > /dev/null
	# JSON output
	$PROG -j $_t.in > /dev/null
	$PROG -c -j $_t.in > /dev/null
	# YAML output
	$PROG -y $_t.in > /dev/null
	# Save comments mode
	$PROG -C $_t.in > /dev/null
	# Save macro mode
	$PROG -M $_t.in > /dev/null
	$PROG -M -C $_t.in > /dev/null
done


